$(document).ready(function() {
    entryManage.init();

});
var _mmg = null;
var details_mmg = null;
var editIndex = undefined;
var entryManage = function(){
    return{
        init: function () {
            _mmg = $('#dg').datagrid({
                url: '/marketing/entryManagePage',
                method: 'post',
                rownumbers: true,
                striped: true,
                nowrap: true,
                pageList: [25, 30, 35],
                idField: 'id', //主键
                onClickRow: 'onClickRow',
                columns: [
                    [
                        {field: 'ck', checkbox: true},
                        {field: 'id', title: 'id', hidden: true},
                        {field: 'EntryNo', title: '报名表ID',width: 80},
                        {field: 'EntryName', title: '报名人姓名', width: 150},
                        {field: 'EntryTel', title: '手机号', width: 150},
                        {field: 'EntryCount', title: '人员数量', width: 160},
                        {field: 'EntryActivity', title: '报名活动', width: 200},
                        {field: 'EntryTime', title: '申请时间', width: 120},
                        {
                             field: 'operation',
                             title: '操作',
                             width: 100,
                             type: 'String',
                             formatter: function (val, item, rowIndex) {
                                      return '<span><a href="#" onclick="entryManage.entourage(\''+ item.Id +'\')"><span style="color:blue;">详情</span></a></span> &nbsp;   <span><a href="#" onclick="activityManageRecycle.delete(\''+ item.Id +'\')"><span style="color:red;">删除</span></a></span>';
                             }
                             },
                    ]
                ],

            }).datagrid("clientPaging");
        },

        //随行人员列表
        entourage: function (Id) {
            details_mmg = $('#details_dg').datagrid({
                    url: '/marketing/entourageManagePage',
                    queryParams: {'id': Id},
                    reload: true,
                    method: 'post',
                    dataType: 'json',
                    singleSelect: true,
                    toolbar: '#tb',
                    onClickRow: 'onClickRow',
                    idField: 'id', //主键
                    columns: [
                        [
                            {field: 'EntourageName', title: '姓名', width: 150 },
                            {field: 'EntourageSex', title: '性别', width: 150},
                            {field: 'EntourageTel', title: '联系方式', width: 168},
                        ]
                    ],
                }
            )
            $('#w').window('open');
        },

        //导出Excel
        Excel: function () {
            $.messager.confirm('', '您确定要导出EXCEL吗', function (r) {
                if (r) {
                    $.ajax({
                        type: 'POST',
                        url: '/marketing/entry/excel',
                        dataType: 'json',
                        success: function (result) {

                            if (result['total'] > 0) {
                                //alert("导出成功！")
                                window.location.href='http://localhost:8080/static/Excel/报名申请单.xlsx'
                            } else {
                                alert("导出失败！")
                            }
                        }
                    })

                    //window.location.href='http://localhost:8080/static/Excel/报名申请单1.xls'
                }
            });
        },

        //测试
        test: function () {
            $.ajax({
                type: 'POST',
                url: '/marketing/test',
                dataType: 'json',
                success: function (result) {
                    console.info(result)
                    if (result['total'] > 0) {
                     alert("successs")

                    } else {

                    }
                }
            })


        },

    }

}
();

